def sortdemo(i):
    a=len(i)
    if a==1:
        return i
    mid=a//2
    left=i[:mid]
    right=i[mid:]
    left_res=sortdemo(left)
    right_res=sortdemo(right)  
    result=merge(left_res,right_res)
    return result
def merge(left,right):
    result=[]
    left_index=0
    right_index=0
    while left_index<len(left) and right_index<len(right):
        if left[left_index]<=right[right_index]:
            result.append(left[left_index])
            left_index+=1
        else:
            result.append(right[right_index])
            right_index+=1
    result+=right[right_index:]
    result+=left[left_index:]
    return result
if __name__=='__main__':
    list_demo=[6,5,7,4,3,1]
    print(sortdemo(list_demo))